from itertools import count

import requests
# server_url = 'http://0.0.0.0:8080/core/button/'

server_url = 'http://0.0.0.0:8090/core/button/'

def get_buttons_by_module_id_list():
    data = {'id': [1, 2, 3]}
    url = server_url + 'get_buttons_by_module_id_list/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())


def test_get_tree_by_module_id_list():
    data = {'id': [1, 2, 3]}
    url = server_url + 'get_tree_by_module_id_list/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

def test_get_tree_by_module_id():
    data = {'id': 1}
    url = server_url + 'get_tree_by_module_id/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

def test_search_button():
    data = {'query_word': '测试'}
    url = server_url + 'search/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r)
    print(r.__sizeof__())
    print(r.json())

def test_add_button():
    data = {'id': 0,'name':'cuiyu1', 'code':7771, 'parent_id':0, 'module_id':2}
    url = server_url + 'add/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

def test_del_button_item():
    data = {'id': 91,'parent_id':0}
    url = server_url + 'del/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

def test_edit_button():
    data = {'id': 90,'name':'ttt', 'code':555, 'parent_id':1, 'module_id':5}
    url = server_url + 'edit/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

get_buttons_by_module_id_list()
# test_get_tree_by_module_id_list()
# test_get_tree_by_module_id()
# test_search_button()
# test_add_button()
# test_del_button_item()
# test_edit_button()




if __name__ == '__main__':
    pass